.with_status(101)
.with_stderr("extra arguments to `rustc` can only be invoked for one target"));
});
+
+test!(build_with_args_to_one_of_multiple_binaries {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+ "#)
+ .file("src/bin/foo.rs", r#"
+ fn main() {}
+ "#)
+ .file("src/bin/bar.rs", r#"
+ fn main() {}
+ "#)
+ .file("src/bin/baz.rs", r#"
+ fn main() {}
+ "#)
+ .file("src/lib.rs", r#" "#);
+
+ assert_that(p.cargo_process("rustc").arg("-v").arg("--bin").arg("bar")
+ .arg("--").arg("-Z").arg("unstable-options"),
+ execs()
+ .with_status(0)
+ .with_stdout(format!("\
+{compiling} foo v0.0.1 ({url})
+{running} `rustc src{sep}lib.rs --crate-name foo --crate-type lib -g \
+ --out-dir {dir}{sep}target{sep}debug [..]`
+{running} `rustc src{sep}bin{sep}bar.rs --crate-name bar --crate-type bin -g \
+ -Z unstable-options [..]`
+",
+ compiling = COMPILING, running = RUNNING, sep = SEP,
+ dir = p.root().display(), url = p.url())));
+});
+
+test!(fails_with_args_to_all_binaries {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+ "#)
+ .file("src/bin/foo.rs", r#"
+ fn main() {}
+ "#)
+ .file("src/bin/bar.rs", r#"
+ fn main() {}
+ "#)
+ .file("src/bin/baz.rs", r#"
+ fn main() {}
+ "#)
+ .file("src/lib.rs", r#" "#);
+
+ assert_that(p.cargo_process("rustc").arg("-v")
+ .arg("--").arg("-Z").arg("unstable-options"),
+ execs()
+ .with_status(101)
+ .with_stderr("extra arguments to `rustc` can only be invoked for one target"));
+});
+
+test!(build_with_args_to_one_of_multiple_tests {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+ "#)
+ .file("tests/foo.rs", r#" "#)
+ .file("tests/bar.rs", r#" "#)
+ .file("tests/baz.rs", r#" "#)
+ .file("src/lib.rs", r#" "#);
+
+ assert_that(p.cargo_process("rustc").arg("-v").arg("--test").arg("bar")
+ .arg("--").arg("-Z").arg("unstable-options"),
+ execs()
+ .with_status(0)
+ .with_stdout(format!("\
+{compiling} foo v0.0.1 ({url})
+{running} `rustc src{sep}lib.rs --crate-name foo --crate-type lib -g \
+ --out-dir {dir}{sep}target{sep}debug [..]`
+{running} `rustc tests{sep}bar.rs --crate-name bar --crate-type bin -g \
+ -Z unstable-options [..]--test[..]`
+",
+ compiling = COMPILING, running = RUNNING, sep = SEP,
+ dir = p.root().display(), url = p.url())));
+});
+
+test!(build_foo_with_bar_dependency {
+ let foo = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+
+ [dependencies.bar]
+ path = "../bar"
+ "#)
+ .file("src/main.rs", r#"
+ extern crate bar;
+ fn main() {
+ bar::baz()
+ }
+ "#);
+ let bar = project("bar")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "bar"
+ version = "0.1.0"
+ authors = []
+ "#)
+ .file("src/lib.rs", r#"
+ pub fn baz() {}
+ "#);
+ bar.build();
+
+ assert_that(foo.cargo_process("rustc").arg("-v").arg("--").arg("-Z").arg("unstable-options"),
+ execs()
+ .with_status(0)
+ .with_stdout(format!("\
+{compiling} bar v0.1.0 ({url})
+{running} `[..] -g -C [..]`
+{compiling} foo v0.0.1 ({url})
+{running} `[..] -g -Z unstable-options [..]`
+",
+ compiling = COMPILING, running = RUNNING,
+ url = foo.url())));
+});
+
+test!(build_only_bar_dependency {
+ let foo = project("foo")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ authors = []
+
+ [dependencies.bar]
+ path = "../bar"
+ "#)
+ .file("src/main.rs", r#"
+ extern crate bar;
+ fn main() {
+ bar::baz()
+ }
+ "#);
+ let bar = project("bar")
+ .file("Cargo.toml", r#"
+ [package]
+ name = "bar"
+ version = "0.1.0"
+ authors = []
+ "#)
+ .file("src/lib.rs", r#"
+ pub fn baz() {}
+ "#);
+ bar.build();
+
+ assert_that(foo.cargo_process("rustc").arg("-v").arg("-p").arg("bar")
+ .arg("--").arg("-Z").arg("unstable-options"),
+ execs()
+ .with_status(0)
+ .with_stdout(format!("\
+{compiling} bar v0.1.0 ({url})
+{running} `[..]--crate-name bar --crate-type lib [..] -Z unstable-options [..]`
+",
+ compiling = COMPILING, running = RUNNING,
+ url = foo.url())));
+});